{extend name="public/list_page"/}
{block name="content"}
<div class="layui-card">
    <div class="layui-card-body">
        <form id="formData" class="layui-form layui-form-pane" autocomplete="off">
            <div class="layui-tab layui-tab-card">
                <ul class="layui-tab-title">
                    <li class="layui-this">公司信息</li>
                    <li>社媒链接</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <div class="layui-form-item">
                            <label class="layui-form-label">公司名称</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" id="name" value="{$info.name}" placeholder="请输入公司名称" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">公司地址</label>
                            <div class="layui-input-block">
                                <input type="text" name="address" id="address" value="{$info.address}" placeholder="请输入公司名称" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">口号</label>
                            <div class="layui-input-block">
                                <input type="text" name="slogan" id="slogan" value="{$info.slogan}" placeholder="请输入公司口号" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">宣传视频</label>
                            <div class="layui-input-block">
                                <input type="text" name="video" id="video" value="{$info.video}" placeholder="请输入宣传视频链接" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">简介</label>
                            <div class="layui-input-block">
                                <textarea class="layui-textarea" name="intro" id="intro" placeholder="请输入公司简介">{$info.intro}</textarea>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">联系人</label>
                            <div class="layui-input-block">
                                <input type="text" name="contact" id="contact" value="{$info.contact}" placeholder="请输入联系人，多个联系人使用英文逗号 “ , ” 进行分隔" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">联系号码</label>
                            <div class="layui-input-block">
                                <input type="text" name="phone" id="phone" value="{$info.phone}" placeholder="请输入号码，多个号码使用英文逗号 “ , ” 进行分隔" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">传真号码</label>
                            <div class="layui-input-block">
                                <input type="text" name="fax" id="fax" value="{$info.fax}" placeholder="请输入传真号码" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">联系邮箱</label>
                            <div class="layui-input-block">
                                <input type="text" name="email" id="email" value="{$info.email}" placeholder="请输入邮箱" class="layui-input">
                            </div>
                        </div>
                    </div>

                    <div class="layui-tab-item">

                        <div class="layui-form-item">
                            <label class="layui-form-label">Linkedin</label>
                            <div class="layui-input-block">
                                <input type="text" name="linked_in" id="linkedIn" value="{$info.linked_in}" placeholder="请输入链接" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">Facebook</label>
                            <div class="layui-input-block">
                                <input type="text" name="facebook" id="facebook" value="{$info.facebook}" placeholder="请输入链接" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">Twitter</label>
                            <div class="layui-input-block">
                                <input type="text" name="twitter" id="twitter" value="{$info.twitter}" placeholder="请输入链接" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">YouTube</label>
                            <div class="layui-input-block">
                                <input type="text" name="youtube" id="youtube" value="{$info.youtube}" placeholder="请输入链接" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">Pinterest</label>
                            <div class="layui-input-block">
                                <input type="text" name="pinterest" id="pinterest" value="{$info.pinterest}" placeholder="请输入链接" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">Instagram</label>
                            <div class="layui-input-block">
                                <input type="text" name="instagram" id="instagram" value="{$info.instagram}" placeholder="请输入链接" class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="btn-block">
                        <button type="button" onclick="sendFormData()" class="layui-btn layui-btn-normal"><i class="fa fa-check"></i>提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary"><i class="fa fa-refresh"></i>重置</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}

{block name="custom"}

{/block}

{block name="js"}
<script>
    layui.use(['form','upload'],function () {
        var $ = layui.jquery,
            form = layui.form,
            upload = layui.upload;

        function uploadTemplate(btn,preview,value,flag,load){
            upload.render({
                elem: btn,
                url: "{:url('company/upload')}",
                multiple: false,
                accept: 'file',
                size: uploadFileSize,
                acceptMime: uploadImgExt,
                before: function (obj) {
                    $(btn).addClass('upload-btn-hide')
                    $(preview).empty()
                    load = layer.load(1, {shade: [0.5, '#FFF'], time: 0})//弹出遮罩层
                },
                done: function (res) {
                    layer.close(load)//关闭遮罩层
                    sucMsg(res.msg)
                    if (res.code == 'suc') {
                        $(preview).append(
                            '<div class="file-items">' +
                            '<div class="handle" data-flag="'+flag+'" data-path="' + res.url + '"><i class="layui-icon layui-icon-delete"></i></div>' +
                            '<img class="cover-preview" src="' + res.url + '">' +
                            '</div>'
                        );

                        $(value).val(res.url)
                    } else {
                        $(btn).removeClass('upload-btn-hide')
                    }
                }
            })
        }
    })

    //删除图片
    $(document).on("click", ".file-items .handle", function (event) {
        //标记
        let flag = $(this).attr('data-flag')

        $(this).parent().remove();
    })

    function sendFormData() {
        //弹出遮罩层，防止多次点击
        var companyInfoLoad = layer.load(1,{shade:[0.5,'#FFF'],time:0})

        let data = $("#formData").serializeArray()

        ajaxRequest("{:url('company/info')}",data,function (res) {
            if (res.code == 'suc'){
                sucMsg(res.msg)
            }else {
                errMsg(res.msg())
            }
        })
        //关闭遮罩层
        layer.close(companyInfoLoad)
    }
</script>
{/block}